{namespace exports}


/**
 * A template for creating an HTML file that documents a class and its members
 *
 * @param title Either "Class" or "Interface".
 * @param cssKind Either "class" or "interface".
 *
 * @param typeName The name of the type being documented.
 * @param? rev The revision of the file being documented.
 *
 * @param? baseClass The base class of this class, if any.
 * @param? interfaces An array of implemented interfaces.
 * @param? extendedInterfaces List of interfaces this interface extends
 *
 * @param? deprecationReason If present, it is the reason that the whole
 *     class or interface is deprecated.
 *
 * @param classDoc The constructor's description.
 * @param constrParams An array of parameter descriptors.
 *
 * @param publicProps An array of public property descriptors.
 * @param publicMethods An array of public method descriptors.
 *
 * @param protectedProps An array of protected property descriptors.
 * @param protectedMethods An array of protected method descriptors.
 *
 * @param privateProps An array of private property descriptors.
 * @param privateMethods An array of private method descriptors.
 *
 * @param inheritedMembers An array of inherited property and method
 *     descriptors.
 */
{template .toClassDoc autoescape="false"}
<html>
  <head>
    <title>
      {$typeName} - {$title} Documentation
    </title>
    <link href="styles/common.css" rel="stylesheet" type="text/css" />
    <link href="styles/class.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <h1 class="class-header">{$title}: <span class="{$cssKind}">{$typeName}</span></h1>
    {if $baseClass}<div class="extends">extends {$baseClass}</div>{/if}
    {if length($interfaces) > 0}
      <div class="implements">implements {foreach $interface in $interfaces}
        {$interface}{if not isLast($interface)},{sp}{/if}
      {/foreach}
      </div>
    {/if}
    {if length($extendedInterfaces) > 0}
      <div class="extends">extends {foreach $interface in $extendedInterfaces}
        {$interface}{if not isLast($interface)},{sp}{/if}
      {/foreach}
      </div>
    {/if}
    
    {if $deprecationReason}
      <h3 class="type-deprecation-header">Deprecated</h3>
      <div class="type-deprecation-reason">{$deprecationReason}</div>
    {/if}
    
    <div class="class-doc">{$classDoc}</div>
    
    <div class="constructor">
      <h3 class="const-head">Constructor</h3>
      
      {foreach $param in $constrParams}
      <div class="mono param">
        <div class="param-head">
          <span class="param-name">{$param.name}</span> : {$param.type}
        </div>
        <div class="param-desc">{$param.desc}</div>
      </div>
        
      {ifempty}
      <div class="no-params">No parameters</div>
      {/foreach}
    </div>
    
    /* Direct class members */
    {call .memberList}
      {param publicProps: $publicProps /}
      {param publicMethods: $publicMethods /}
      
      {param protectedProps: $protectedProps /}
      {param protectedMethods: $protectedMethods /}
      
      {param privateProps: $privateProps /}
      {param privateMethods: $privateMethods /}
    {/call}
    
    /* Inherited members */
    {if $cssKind == 'class' and length($inheritedMembers) > 0}
      {foreach $superType in $inheritedMembers}
        <div class="inherits">
        <span class="mono inherits-from">Inherited from {$superType.from}</span>
        {call .memberList data="$superType" /}
      {/foreach}
      {foreach $superType in $inheritedMembers}
        </div>
      {/foreach}
    {elseif $cssKind == 'interface' and length($inheritedMembers) > 0}
      {foreach $superType in $inheritedMembers}
        <div class="inherits">
        <div class="mono inherits-from">Required by {$superType.from}</div>
        {call .memberList data="$superType" /}
        </div>
      {/foreach}
    {/if}
    
    {if $rev}<hr class="footer" /><div class="rev">revision: {$rev}</div>{/if}
  </body>
</html>
{/template}


/**
 * Render a list of class members (properties and methods)
 *
 * @param publicProps An array of public property descriptors.
 * @param publicMethods An array of public method descriptors.
 *
 * @param protectedProps An array of protected property descriptors.
 * @param protectedMethods An array of protected method descriptors.
 *
 * @param privateProps An array of private property descriptors.
 * @param privateMethods An array of private method descriptors.
 *
 * @param cssKind Either "class" or "interface".
 */
{template .memberList autoescape="false"}
<div class="public-props">
<h3 class="props-head">Public Properties</h3>
{call .propList}
  {param props: $publicProps /}
{/call}

<h3 class="methods-head">Public Methods</h3>
{call .methodList}
  {param methods: $publicMethods /}
  {param isInterface: $cssKind == 'interface' ? true : false /}
{/call}
</div>

<div class="protected-props">
<h3 class="props-head">Protected Properties</h3>
{call .propList}
  {param props: $protectedProps /}
{/call}

<h3 class="methods-head">Protected Methods</h3>
{call .methodList}
  {param methods: $protectedMethods /}
  {param isInterface: $cssKind == 'interface' ? true : false /}
{/call}
</div>

<div class="private-props">
<h3 class="props-head">Private Properties</h3>
{call .propList}
  {param props: $privateProps /}
{/call}

<h3 class="methods-head">Private Methods</h3>
{call .methodList}
  {param methods: $privateMethods /}
  {param isInterface: $cssKind == 'interface' ? true : false /}
{/call}
</div>
{/template}


/**
 * Render a list of class properties.
 *
 * @param props An array of property descriptors.
 */
{template .propList autoescape="false"}
{foreach $prop in $props}
<div class="mono prop">
  <div class="prop-head">
    <span class="prop-name">
      <a name="{$prop.name}">{$prop.name}</a>
    </span> : {$prop.type}
  </div>
  <div class="prop-desc">{if $prop.desc}
    {$prop.desc}
  {else}
    <em>No description.</em>
  {/if}
  </div>
</div>

{ifempty}
<div class="no-props">None.</div>
{/foreach}
{/template}


/**
 * Render a list of class methods.
 *
 * @param methods An array of method descriptors.
 * @param isInterface Whether or not the type being documented is an interface.
 */
{template .methodList autoescape="false"}
{foreach $method in $methods}
<div class="mono prop">
  <div class="prop-head">
    {if $method.isOverride}
      <em>@override</em>{sp}
    {/if}
    {if $method.isAbstractMethod or $isInterface}
      <em>abstract</em>{sp}
    {/if}
    <span class="prop-name">
      <a name="{$method.name}"{if $method.deprecationReason}
        class="deprecated"{/if}>{$method.name}</a>
    </span>
    {if $method.returns and $method.returns.type}
      {sp}&#8658; {$method.returns.type}
    {/if}
  </div>
  {if $method.deprecationReason}
    <div class="deprecation-reason">
      <strong>Deprecated:</strong> {$method.deprecationReason}
    </div>
  {/if}
  
  <div class="prop-desc">
  {if $method.desc}
    {$method.desc}
  {else}
    <em>No description.</em>
  {/if}
  </div>
  
  <div class="method-params">
  {if $method.params and length($method.params) > 0}
    <em><strong>Method Parameters</strong></em>
    {foreach $param in $method.params}
      <div class="mono prop">
        <div class="prop-head">
          <span class="prop-name">
            <a name="{$param.name}">{$param.name}</a>
          </span> : {$param.type}
        </div>
        <div class="prop-desc">{if $param.desc}
          {$param.desc}
        {else}
          <em>No description.</em>
        {/if}
        </div>
      </div>
    {/foreach}
  {else}
    <em>No method parameters.</em>
  {/if}
  
  
  {if $method.returns}
    <div class="mono prop">
      <div class="prop-head">
        <span class="prop-name">
          <em>returns</em>
        </span> &#8658; {$method.returns.type}
      </div>
      <div class="prop-desc">{if $method.returns.desc}
        {$method.returns.desc}
      {else}
        <em>No description.</em>
      {/if}
      </div>
    </div>
  {/if}
  </div>
</div>

{ifempty}
<div class="no-props">None.</div>
{/foreach}
{/template}


/**
 * Create a test function for the build script.
 */
{template .test}
Success.
{/template}
